package com.noexcs.forum.event;

import com.alibaba.fastjson.JSONObject;
import com.noexcs.forum.entity.Event;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;

/**
 * @author noexcs
 * @since 6/4/2022 1:24 AM
 */
public class EventProducer {

    @Autowired
    private KafkaTemplate kafkaTemplate;

    public void fireEvent(Event event){
        kafkaTemplate.send(event.getTopic(), JSONObject.toJSONString(event));
    }
}
